﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TA.Turbo.Controls
{
	/// <summary>
	/// Definition of a CSS class property which needs to be stored as part of the attribute collection of the control.
	/// </summary>
	public class CssClassPropertyDefinition : PropertyDefinition<string>
	{
		#region PUBLIC
		#region INIT
		/// <summary>
		/// Ctor.
		/// </summary>
		public CssClassPropertyDefinition()
			: base("CssClass", "C", "")
		{
			this.IsHTML = true;
		}
		#endregion
		#region EVENTS
		#endregion
		#region PROPS
		#endregion
		#region METHODS
		#endregion
		#endregion
		#region INTERNAL
		#region CONST/STATIC
		#endregion
		#region VARS
		#endregion
		#region PROPS
		#endregion
		#region METHODS
		#region INIT
		#endregion
		#region DATA
		#endregion
		#region HANDLERS
		#endregion
		#endregion
		#endregion
		/// <summary>
		/// Gets the value of this property for the specified control.
		/// </summary>
		/// <param name="control"></param>
		/// <returns></returns>
		protected internal override string GetValue(TControl control)
		{
			if (string.IsNullOrEmpty(control.Attributes["class"]))
				return this.DefaultValue;
			return control.Attributes["class"];
		}
		/// <summary>
		/// Sets the value of this property for the specified control.
		/// </summary>
		/// <param name="control"></param>
		/// <param name="value"></param>
		/// <returns></returns>
		protected override void SetValue(TControl control, string value)
		{
			control.Attributes["class"] = value;
		}
	}
}
